import pandas as pd 
import matplotlib.pyplot as plt 

plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签

def cleaned_data(json_data):
    #进行数据得初步清洗得出基础信息
    china_total = json_data['chinaTotal']
    china_day_lists = json_data['chinaDayList']

    daily_data = []
    daily_increase = []
    daily_total = []
    
    for china_day_list in china_day_lists:
        daily_data.append(china_day_list['date'])
        daily_increase.append(china_day_list['today']['confirm'])
        daily_total.append(china_day_list['total']['confirm'])

    data_pack = {'daily_data':daily_data,
                'daily_increase':daily_increase,
                'daily_total':daily_total}

    return data_pack

def process_data(data_pack):
    data_pack = pd.DataFrame(data_pack)


def show_image(data_pack):
    '''用于进行分析后数据得显示'''
    plt.figure(figsize = (12,10))
    plt.subplot(2,1,1)
    plt.plot(data_pack["daily_data"],data_pack['daily_increase'])
    plt.xticks(rotation = 45,size = 'x-small')
    plt.title('新冠疫情推移图')
    plt.subplot(2,1,2)
    plt.plot(data_pack["daily_data"],data_pack['daily_total'])
    plt.xticks(rotation = 45,size = 'x-small')
    

    plt.show()
